package cn.edu.hpu.util;

import java.util.List;


public class Pager<T> {
	private int pagesize=5;
	private int totalcount;
	private int totalpages;
	private int nowpagenum;
	private int startlinenum;
	private List<T> result;
	
	public Pager()
	{
		
	}
	public Pager(int nowpagenum,int totalcount){
		setTotalcount(totalcount);
		setNowpagenum(nowpagenum);
	}
	public int getPagesize() {
		return pagesize;
	}
	public void setPagesize(int pagesize) {
		this.pagesize = pagesize;
	}
	public int getTotalcount() {
		return totalcount;
	}
	public void setTotalcount(int totalcount) {
		this.totalcount = totalcount;
	}
	public int getTotalpages() {
		int totalpages = getTotalcount()/getPagesize();
		if (getTotalcount()%getPagesize() != 0) {
			totalpages += 1;
		} 
		return totalpages;
	}
	
	public int getNowpagenum() {
		return nowpagenum;
	}
	public void setNowpagenum(int nowpagenum) {
		if (nowpagenum<1) {
			nowpagenum = 1;
		} else if(nowpagenum>getTotalpages()){
			nowpagenum = getTotalpages();
		}
		this.nowpagenum = nowpagenum;
	}
	public int getStartlinenum() {
		int startlinenum =(getNowpagenum()-1)*getPagesize();
		return startlinenum;
	}
	
	public List<T> getResult() {
		return result;
	}
	public void setResult(List<T> result) {
		this.result = result;
	}
	
	
}
